﻿<common:LayoutAwarePage x:Class="Mutzl.Samples.VideoApp.RssContent.View.MainView"
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:common="using:Mutzl.Samples.VideoApp.Common"
                        xmlns:controls="using:Mutzl.Samples.VideoApp.Controls"
                        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                        x:Name="PageRoot"
                        DataContext="{Binding Main,
                                              Source={StaticResource RssContentLocator}}"
                        mc:Ignorable="d">

    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Viewbox Grid.RowSpan="2" Stretch="UniformToFill">
            <Grid>
                <Image Source="ms-appx:///Assets/background.png" />
                <MediaElement IsLooping="True" Source="ms-appx:///Assets/background.mp4" />
            </Grid>
        </Viewbox>

        <!--  Horizontal scrolling grid used in most view states  -->
        <controls:VariableGridView x:Name="ItemGridView"
                                   Grid.RowSpan="2"
                                   AutomationProperties.AutomationId="ItemGridView"
                                   AutomationProperties.Name="Grouped Items"
                                   IsItemClickEnabled="True"
                                   IsSwipeEnabled="false"
                                   ItemClick="ItemView_ItemClick"
                                   ItemTemplate="{StaticResource Standard250x250ItemTemplate}"
                                   ItemsSource="{Binding Videos}"
                                   Padding="116,137,40,46"
                                   SelectionMode="None">
            <GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VariableSizedWrapGrid VerticalAlignment="Center"
                                           ItemHeight="250"
                                           ItemWidth="250"
                                           MaximumRowsOrColumns="3" />
                </ItemsPanelTemplate>
            </GridView.ItemsPanel>


        </controls:VariableGridView>

        <!--  Vertical scrolling list only used when snapped  -->
        <ListView x:Name="ItemListView"
                  Grid.Row="1"
                  Margin="0,-10,0,0"
                  AutomationProperties.AutomationId="ItemListView"
                  AutomationProperties.Name="Grouped Items"
                  IsItemClickEnabled="True"
                  IsSwipeEnabled="false"
                  ItemClick="ItemView_ItemClick"
                  ItemTemplate="{StaticResource Standard80ItemTemplate}"
                  ItemsSource="{Binding Videos}"
                  Padding="10,0,0,60"
                  SelectionMode="None"
                  Visibility="Collapsed" />

        <!--  Back button and page title  -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button x:Name="BackButton"
                    Click="GoBack"
                    IsEnabled="{Binding Frame.CanGoBack,
                                        ElementName=PageRoot}"
                    Style="{StaticResource BackButtonStyle}" />
            <TextBlock x:Name="PageTitle"
                       Grid.Column="1"
                       IsHitTestVisible="false"
                       Style="{StaticResource PageHeaderTextStyle}"
                       Text="{StaticResource AppName}" />
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!--  Visual states reflect the application's view state  -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape" />
                <VisualState x:Name="Filled" />

                <!--  The entire page respects the narrower 100-pixel margin convention for portrait  -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}" />
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="96,137,10,56" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}" />
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
